<?php
/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Game
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
?>

<?php 

$game = $this->game;

    $src = $game->getSwfUrl();
    $width = $game->width;
    $height = $game->height;
    
    if (!$game->embed_code && isset($this->max_width) && $this->max_width < $width) {
      $height = $height * $this->max_width / $width;
      $width = $this->max_width;
    }
    
    if ($this->force_width) {
      $width = $this->force_width;
    }
    if ($this->force_height) {
      $height = $this->force_height;
    }
    
?>

<?php if ($game->embed_code): ?>
  <?php 
    $code = $game->embed_code;
    $placeholders = array("{{swf}}" => $src, "{{width}}" => $width, "{{height}}" => $height);
    foreach ($placeholders as $key => $value) {
      $code = str_replace($key, $value, $code);
    }
    echo $code;
  ?>
<?php else: ?>
<object class="game_embed_code" width="<?php echo $width; ?>" height="<?php echo $height; ?>">
      <param name="allowFullScreen" value="true">
      <param name="allowScriptAccess" value="always">
      <embed src="<?php echo $src; ?>" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="<?php echo $width; ?>" height="<?php echo $height; ?>" wmode="transparent">
      <param name="wmode" value="transparent">
</object>
<?php endif; ?>    